home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Kernel / Em / unixIO.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-17  |  1.1 KB  |  68 lines

  1. #include <stdio.h>
  2. #include "Kernel/h/emTypes.h"
  3. #include "Kernel/h/kmdTypes.h"
  4.  
  5. void UnixStreamPutChar(f, c)
  6. FILE *f;
  7. char c;
  8. {
  9. #ifdef xsimul
  10.   fprintf(f, "%c", c);
  11. #else
  12.   printf("%c", c);
  13. #endif
  14. }
  15.  
  16. void UnixStreamPutInt(f, d, w)
  17. FILE *f;
  18. int d, w;
  19. {
  20. #ifdef xsimul
  21.   if (w < 0) fprintf(f, "%0*d", -w, d);
  22.   else fprintf(f, "%*d", w, d);
  23. #else
  24.   if (w < 0) printf("%0*d", -w, d);
  25.   else printf("%*d", w, d);
  26. #endif
  27. }
  28.  
  29. void UnixStreamPutReal(f, d)
  30. FILE *f;
  31. int d;
  32. {
  33. #ifdef xsimul
  34.   fprintf(f, "%g", * (float *) &d);
  35. #else
  36.   printf("%g", * (float *) &d);
  37. #endif
  38. }
  39.  
  40. void UnixStreamPutString(f, s)
  41. FILE *f;
  42. StringPtr s;
  43. {
  44. #ifdef xsimul
  45.   fprintf(f, "%.*s", s->sizeInBytes, (char *)&s->data[0]);
  46. #else
  47.   printf("%.*s", s->sizeInBytes, &s->data[0]);
  48. #endif
  49. }
  50.  
  51. void UnixStreamFlush(f)
  52. FILE *f;
  53. {
  54. #ifdef xsimul
  55.   (void) fflush(f);
  56. #endif
  57. }
  58.  
  59. void UnixStreamInit()
  60. {
  61.     DebugMsg(5, "Unix Stream Init\n");
  62.     KMDSetProcedure(UnixStreamFlush);
  63.     KMDSetProcedure(UnixStreamPutString);
  64.     KMDSetProcedure(UnixStreamPutReal);
  65.     KMDSetProcedure(UnixStreamPutInt);
  66.     KMDSetProcedure(UnixStreamPutChar);
  67. }
  68.